package com.nine.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.nine.dao.TestPlanDao;
import com.nine.entity.PageSort;
import com.nine.entity.TestPlan;
import com.nine.service.TestPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:测试计划的service接口的实现类
 * @Author:LouFangRui
 * @Date:2022/7/1 10:03
 */
@Service
public class TestPlanServiceImpl implements TestPlanService {
	@Autowired
	private TestPlanDao testPlanDao;

	/**
	 * 查询全部and模糊查询
	 * */
	@Override
	public List<TestPlan> selectAllPlan(TestPlan testPlan) {
		List<TestPlan> testPlanList = testPlanDao.selectAllPlan(testPlan);
		return testPlanList;
	}

	/**
	 * 添加
	 * */
	@Override
	public int addTestPlan(TestPlan testPlan) {
		int i = testPlanDao.addTestPlan(testPlan);
		return i;
	}

	/**
	 * 修改
	 * */
	@Override
	public int updatePlanById(TestPlan testPlan) {
		int i = testPlanDao.updatePlanById(testPlan);
		return i;
	}

	/**
	 * 行内删除and批量删除
	 * */
	@Override
	public int deletePlanById(String[] testPlanId) {
		int i = testPlanDao.deletePlanById(testPlanId);
		return i;
	}

	/**
	 * 分页查询
	 * */
	@Override
	public Page selectAllPlanByPage(PageSort pageSort, TestPlan testPlan) {
		//开始分页
		Page<TestPlan> page= PageHelper.startPage(pageSort.getPage(),pageSort.getLimit());
		//调用全部查询获得所有数据
		List<TestPlan> testPlans =testPlanDao.selectAllPlan(testPlan);
		//获得分页后的数据
		Page listWithPage= (Page) testPlans;
		return listWithPage;
	}
}
